package main

import (
	"github.com/veandco/go-sdl2/sdl"
)

const (
	W = 670
	H = 620
)

func main() {
	sdl.Init(sdl.INIT_EVERYTHING)
	defer sdl.Quit()

	window, _ := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
		W, H, sdl.WINDOW_SHOWN)
	defer window.Destroy()

	renderer, _ := sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
	defer renderer.Destroy()

	running := true
	for running {
		for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
			switch event.(type) {
			case *sdl.QuitEvent:
				println("Quit")
				running = false
				break
			}
		}
		//renderer.SetDrawColor(128, 128, 128, 255)
		//renderer.Clear()

		rect := sdl.Rect{W / 4, H / 4, W / 2, H / 2}
		renderer.SetDrawColor(255, 0, 0, 255)
		renderer.FillRect(&rect)

		outline := sdl.Rect{W / 6, H / 6, W * 2 / 3, H * 2 / 3}
		renderer.SetDrawColor(0, 255, 0, 255)
		renderer.DrawRect(&outline)

		renderer.SetDrawColor(0, 0, 255, 255)
		renderer.DrawLine(0, H/2, W, H/2)

		renderer.SetDrawColor(255, 255, 0, 255)
		for i := 0; i < H; i += 4 {
			renderer.DrawPoint(W/2, int32(i))
		}

		renderer.Present()
		sdl.Delay(16)
	}
}
